home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-15 / portest2.zip / TESTPORT.DOC < prev   
Text File  |  1992-09-17  |  25KB  |  510 lines

  1.    Slickware is Copy(c)right 1989,1992 by Gary M. Raymond, New Orleans, La.
  2.         Slick Port Modem Register Test Program V1.1 by Gary M. Raymond
  3.  
  4.                           Simple <Software> Company
  5.                               HOME of SlickWare
  6.  
  7.                               Gary M. Raymond
  8.                                 P.O.Box 8184
  9.                            New Orleans, La.  70182
  10.                                (504) 288-6550
  11.                             Compuserve 70613,3165
  12.  
  13.  
  14.  
  15.    Files Provided:
  16.    ====================================================================
  17.  
  18.    TESTPORT.COM   Serial Port Test Utility.
  19.    TESTPORT.DOC   This document.
  20.  
  21.    TestPort will run on just about any version of DOS and with any
  22.    amount of RAM. If nothing else, TestPort will assist you in learning
  23.    more about serial communications and understanding your modem. Having
  24.    written and supported several terminal programs over the past seven
  25.    years, I have long ago realized that most problems involving terminal
  26.    software are actually modem or modem configuration problems. This
  27.    utility should take some of the mystery away from configuring,
  28.    understanding, and diagnosing serial communications hardware. If for
  29.    no other reason than curiosity, you owe it to your modem to use
  30.    TestPort at least once and read through this file. TestPort was
  31.    written in ASIC, and, I will gladly supply the source code with your
  32.    registration, if requested.
  33.  
  34.    ====================================================================
  35.    TestPort is a basic, easy to use, modem diagnostic tool. Although the
  36.    information TestPort provides will at first be seemingly cryptic to
  37.    the novice user, it can easily be learned and put to good use.  Bit
  38.    mapping the modem registers provides a wealth of information about
  39.    the state of your modem. Your modem is both configured and monitored
  40.    through these registers or electronic switches. Everything from baud
  41.    rate to data parity is determined by the one (on) or zero (off) bit
  42.    settings in these registers. Particular register bits are also used
  43.    to inform the terminal program that a character has arrived or is
  44.    ready to be transmitted along with numerous other useful information.
  45.  
  46.    According to the IBM scheme of things, you could have as many as
  47.    65,536 port addresses. These ports have an address in the hardware
  48.    set up according to IBM's scheme. Each address points to a one byte
  49.    location called a base address. Since we can both set and retrieve
  50.    bits in these bytes we refer to them as maskable base registers. Each
  51.    of the next subsequent nine bytes (BASE+1, BASE+2 etc) form that
  52.    ports general register set as outlined in the text below. Serial
  53.    communication ports begin with COM Port number one (COM1) with an
  54.    address assigned by IBM as decimal 1016 or 3F8 hex. Hence, the
  55.    address for the COM1 port register is 3F8. This is the place where a
  56.    byte of data is received (3F8 - Received Data Register) or sent (3F8
  57.    - Transmitter Holding Register) depending on requirements at the
  58.    moment. Therefore the base address allows indirect access to both the
  59.    THR and RDR (plus BRDL when bit 7 of LCR is set). The next register
  60.    (the IER) is located at this base address plus one, (3F8 + 1 = 3F9)
  61.    and so on.
  62.  
  63.    There are two general methods of obtaining bytes of data from a
  64.    serial port after it has been set up. The first involves stoping
  65.    every so often and looking to see if a byte has arrived, and if so,
  66.    taking it. This method of polling the modem registers is ok when
  67.    working at very slow baud rates. Polling is the method used by the
  68.    PC's Basic Input Output Service (BIOS firmware.) Unfortunately, if a
  69.    byte of data arrives before we have had a change to remove the
  70.    previous one, information can be lost. To overcome this drawback of
  71.    polling we can force the PC to react to the arrival of a byte by
  72.    removing and saving it in a special storage area until we have time
  73.    to use it. This is done by designing a special Interrupt Service
  74.    Routine (ISR) that will be activated instantly (no matter what else
  75.    the PC may be doing) to collect and store the byte of data. This is
  76.    referred to as an "interrupt on receive" terminal program, such as
  77.    our product, SLICK terminal.
  78.  
  79.    There are many things that can go wrong when installing a modem
  80.    on your computer. Usually, problems are evenly divided between
  81.    hardware and software configuration errors. In general, the modem
  82.    itself must be mechanically set, via jumper pins or dip switches,
  83.    to address whatever available serial port is usable on your PC.
  84.    The selected port must also be paired with an interrupt request line
  85.    (IRQ). Note, no two serial devices (examp: modem and mouse) may share
  86.    actively the same serial port IRQ address. Some modems force, or
  87.    allow you to force, certain register bits either high (1) or low (0)
  88.    in lieu of preferred software control. TestPort is useful in
  89.    EXAMINING all of the register settings that occur as a results of
  90.    these various configurations. Improper configuration of software is
  91.    another problem. Here, there are generally three areas of trouble.
  92.    Improper comm port, interrupt and modem command (initialization)
  93.    string settings. So, to review, One: the serial services must first
  94.    be available on the PC. Two: both the modem and terminal software
  95.    must agree in settings with the PC hardware you are attempting to
  96.    access. And finally, the modem initialization command string must
  97.    correctly complete the job of setting any other registers that
  98.    require attention, such as setting FAX mode on or off, hardware error
  99.    correction enabled or disabled, etc. etc. For what its worth, just
  100.    one wrong AT command in the string will cause the entire string to
  101.    FAIL. So, if your particular brand modem does not use &D1 (set dtr)
  102.    as an example, and, it is inserted into your complete string, such as
  103.    ATM1S0=0V1X4&D1S7=45, then the entire string will fail returning an
  104.    error message, leaving your modem still waiting to be configured.
  105.  
  106.    ====================================================================
  107.    USING TestPort's register mapping ability:
  108.  
  109.    To run TestPort with mapping action, you must pass the active port
  110.    number via a command parameter. TestPort will work on the four
  111.    standard IBM default ports of 1 (3F8), 2 (2F8), 3 (3E8), and 4 (2E8).
  112.    Let's assume your modem is configured to operate using COM2. Type
  113.    TESTPORT 2 at the DOS prompt. In most cases, you will really want to
  114.    do this while your terminal program is active. You do this by
  115.    dropping to DOS from within your terminal program, then executing
  116.    TestPort. Most all Terminal programs have a drop to DOS feature,
  117.    although it might be called something else. TestPort does a passive
  118.    read only on these registers and therefore will in no way alter or
  119.    change their bit settings. By using the drop to dos feature, which
  120.    allows the modem code to remain loaded in ram, you eliminate the
  121.    possibility that any modem registers will be inadvertently altered,
  122.    by your terminal program, before you get to read the registers. Some
  123.    terminal programs also have features that allow the naming and
  124.    execution of any external dos utility via a combination of trigger
  125.    hot keys. This is a MUCH better way of quickly running TestPort.
  126.    Don't forget in either case to pass the active port number in use.
  127.    (i.e. TESTPORT 2.)  If TestPort is executed as an external utility,
  128.    screen output data will remain until a key is pressed. This will give
  129.    you opportunity to hit Shft PrtSc and save a copy of the screen to
  130.    your printer for evaluation and analysis. If you do not have a
  131.    printer, you should make a long hand record on paper.
  132.  
  133.    USING TestPort's UART finder:
  134.  
  135.    Running TestPort without a port parameter will cause TestPort to
  136.    cycle through the four common UART addresses looking for an active
  137.    (U)niversal (A)synchronous (C)ommunications (C)ontroller. (8250 IC)
  138.    If active port addresses are located, TestPort will notify you of
  139.    those that appeared active. Notice, I said appeared active. It is
  140.    possible to have two serial ports but only one terminated to a
  141.    modem. The other may be just a jack on the rear of your PC, there
  142.    for some later expansion. A simple serial card with its open jack
  143.    will still show as an active port.
  144.  
  145.    Screen Output:
  146.    ------------------------------------------------------------------------
  147.    The Correct Syntax is TESTPORT #, (# to test), i.e. TESTPORT 4,
  148.    however, TestPort will now try to determine what if any serial
  149.    port is responding to TestPort's Inquiries....................
  150.  
  151.    COM1 appears to have an active UART!
  152.    COM2 appears to be inactive.
  153.    COM3 appears to be inactive.
  154.    COM4 appears to have an active UART!
  155.  
  156.    Enter Port# to test or Esc to exit ->
  157.  
  158.    In five seconds type AT <Enter>, active port will echo OK or 0, else Esc!
  159.    ------------------------------------------------------------------------
  160.  
  161.    Although this kind of information is by far un-conclusive, it does
  162.    give you enough insights to continue experimenting. In the case of
  163.    the information given above, the modem must be attached to either
  164.    COM1 or COM4. To determine which it is, try entering 1 first. If
  165.    there is no echoing of your keystroke or an OK reply to AT (the modem
  166.    attention command) the probability is COM1 is not the port connected
  167.    to your modem. Now try 4. This should test ok! More than likely, COM1
  168.    is an extra, as of yet unused, serial adapter.
  169.  
  170.    Although this testing facility is only a raw polling terminal, set to
  171.    1200 baud, N81, it can easily be used for simple task, like dialing
  172.    out to test other modems etc. Try typing ATH1 and see if you hear
  173.    your modem take the line off hook....ATH0 to replace it. Fun hun?
  174.  
  175.    ====================================================================
  176.    SCREEN GENERATED BY TESTPORT when mapping registers:
  177.  
  178.    When TestPort is run, it produces the following screen, indicating
  179.    the various one byte registers that have been read, their decimal,
  180.    hex, and (binary) bit map values. It's those bit settings you are
  181.    most interested in. The two indirect registers (THR and RDR) read
  182.    via the base register are not useful here. However, those two plus
  183.    the eight indicated account for the 10 registers of a UART chip.
  184.  
  185.          *******************************************************
  186.              Modem Register Bit Map by Gary M. Raymond SSC
  187.                         Phone (504) 288-6550
  188.  
  189.          Modem Registers     Dec Value    Hex Value     Bit Map
  190.                                                         76543210
  191.          IER (Int Enable)             0           00    00000000
  192.          IIR (Int ID)                 1           01    00000001
  193.          LCR (Line Control)           3           03    00000011
  194.          MCR (Modem Cont)             8           08    00001000
  195.          LSR (Line Status)           97           61    01100001
  196.          MSR (Modem Status)          48           30    00110000
  197.          BRDL (Low Register)          6           06    00000110
  198.          BRDH (Hi  Register)          0           00    00000000
  199.          *******************************************************
  200.  
  201.  
  202.          Hit Any Key to Exit!
  203.  
  204.  
  205.  
  206.    NOTE: Bit positions are read left to right, starting with position
  207.          0 (zero) and ending with 7. This accounts for a full byte of
  208.          eight bits.
  209.  
  210.    ====================================================================
  211.    SAMPLE USES for TESTPORT:
  212.  
  213.    Q) My modem wont hang up, what do I look for?
  214.    A) Look at bits 0 and 1 of MCR after starting your terminal program
  215.       but before dialing a number. They should both be set to 1. If not
  216.       check to see if your modem requires external dip switch settings
  217.       to force DTR, RTS or software AT commands like &D2 and &C1.
  218.  
  219.    Q) How can I tell if my terminal program is interrupt driven or
  220.       a polling BIOS type?
  221.    A) Look at bit 0 of IER, it will be set to 1 if the terminal is
  222.       interrupt driven. Also, bit 3 of MCR is usually set to 1 as
  223.       well. These bits are set to 0 (zero) in a polling terminal.
  224.  
  225.    Q) My modem wont respond on COM2.
  226.    A) Run TESTPORT 2. If If you see each modem register returning FF hex
  227.       (dec 255 or 11111111 binary) odds are this port is not activated
  228.       correctly via pin or dip settings on the modem card. Check your
  229.       modem manual for correct pin or dip switch settings.
  230.  
  231.    Q) How can I tell what Baud rate my modem is locked at?
  232.    A) First, run TestPort and obtain the BRDL and BRDH register values.
  233.       Then cross reference them with the Baud Rate Value chart in this
  234.       document file.
  235.  
  236.    Q) Can I use TestPort to place a call to a BBS?
  237.    A) Yes, but it's VERY limited as a polling terminal and not intended
  238.       for that kind of application. No protocols, no dial directory, no
  239.       no nothing, just a bare foot terminal!
  240.  
  241.    Q) My modem and software configured for COM3 is brain dead, can
  242.       TestPort help?
  243.    A) You bet! Some serial communications software, especially tsr type,
  244.       use BIOS services for communicating with the serial ports. BIOS
  245.       then depends on DOS to insert the correct port addresses into the
  246.       BIOS area of memory. Some versions of DOS fail to place the
  247.       default addresses for COM3 and COM4 in the required BIOS area of
  248.       memory. TestPort overcomes this limitation by poking ALL of the
  249.       IBM default addresses (3F8 - 2F8 - 3E8 - 2E8) into the correct
  250.       area of bios memory starting at segment 0040. This feature is
  251.       automatic anytime you run TestPort in any mode. To cancel out
  252.       these values, you only need reboot the PC. I will also provide a
  253.       seperate utility (PCA.COM) that can be used via your autoexec.bat
  254.       to insure these addresses are always available after bootup.
  255.  
  256.    Q) My terminal program has a host mode that allows remote access to
  257.       DOS via a redirection statement in a batch file. Only guess what?
  258.       It locks up my computer. Can TestPort help me?
  259.    A) Well, maybe. There are many computers (clones or otherwise) that
  260.       just do not take kindly to re-direction. (CTTY COM1 or CTTY > AUX1
  261.       type calls) If the reason is due to the problem outlined in the
  262.       answer above, TestPort or PCA will solve it. If not, there is
  263.       a device driver in the public domain called GateWay that usually
  264.       will accept re-direction. It can be found on most BBS'es. One
  265.       nice thing about GateWay is it still allows access to the host
  266.       keyboard and monitor; simple re-direction does not.
  267.  
  268.    Q) Can I use TestPort to see the default and or active settings
  269.       of all registers in my modem?
  270.    A) Yes, actually, you can do that with any terminal program. To use
  271.       TestPort, type TESTPORT at the dos prompt. Select the active port
  272.       number and wait five seconds for the terminal to respond. Type
  273.       AT&V then hit enter. On some older modems you cannot dump the
  274.       entire register set and you must poll each individually. Say
  275.       you want to see the present value in S7, type ATS7? and so on.
  276.  
  277.    Q) My old modem had a volume control on the card. My new one does
  278.       not. Can TestPort save my marriage and turn down the volume?
  279.    A) Yes, and again, it can also be done with your present terminal.
  280.       By default most modems allow the speaker on at full volume. You
  281.       can control this by resetting the M and L registers. ATM1 will
  282.       turn off the sound after a connect and ATL0 will reduce the volume
  283.       to the lowest setting. Of cource, these switches belong together
  284.       in your initialization command string. (ATM1L1etc.etc.etc.)
  285.  
  286.    ====================================================================
  287.    MODEM REGISTER BIT MAP DATA:
  288.  
  289.        For general purpose information, the port addresses of
  290.        these registers are as follows:
  291.  
  292.        BASE = COMPORT ADDRESS  (COM1 = 3F8h)
  293.        Therefore, MCR for COM1 equals 3F8h + 4 or 3FCh
  294.  
  295.        Ten Modem Registers
  296.        ---------------------------------------------
  297.        THR,RDR, *BRDL =  BASE
  298.        IER,     *BRDH =  BASE  + 1  ;  Interrupt Enable Register
  299.        IIR            =  BASE  + 2  ;  Interrupt Identification Register
  300.        LCR            =  BASE  + 3  ;  Line Control Register
  301.        MCR            =  BASE  + 4  ;  Modem Control Register
  302.        LSR            =  BASE  + 5  ;  Line Status Register
  303.        MSR            =  BASE  + 6  ;  Modem Satus Register
  304.        ---------------------------------------------
  305.                 *requires bit 7 set to 1 in LCR for access
  306.    ====================================================================
  307.  
  308.        IER  BIT MAPPING   (Interrupt Enable Register)
  309.        ---------------------------------------------
  310.        BIT     Activates             Action
  311.        0    =  Data Received         Read RDR
  312.        1    =  THR empty             Output to THR
  313.        2    =  Data error/break      Read LSR
  314.        3    =  MSR change            Read MSR
  315.        4    =  zero
  316.        5    =  zero
  317.        6    =  zero
  318.        7    =  zero
  319.  
  320.        Although the 8250 Uart has 10 one byte registers, only seven have
  321.        direct access, and of the seven, three of these are used
  322.        redundantly to gain access to the three non directly accessible
  323.        registers. This indirect access is achieved by setting bit 7 of
  324.        LSR to 1. Then, the BRDL and BRDH registers are accesses at BASE
  325.        and BASE + 1. These two registers are used to lock the port baud
  326.        rate. The BRD (Baud Rate Divisor) is a 16 bit number (two bytes)
  327.        and therefore requires two (one byte) register access through
  328.        BASE and BASE + 1. Interesting enough, the high byte is only
  329.        necessary for baud rates of 300 or below. At 1200 or higher BRDH
  330.        is set at zero. The formula for calculating the BRD value
  331.        demonstrates why.
  332.  
  333.                       UART CLOCK SPEED (1.8432mhz)
  334.               BRD =   ----------------------------
  335.                       16 x bit transfer rate (not really baud)
  336.  
  337.                       1,843,200
  338.               BRD =   ---------   =   256 or    110000000  or 100h
  339.                       16 x 300
  340.                                                 B   B
  341.                                                 R   R
  342.                                                 D   D
  343.                       breaking the result into  H   L
  344.                       two bytes produces =      1 & 1000000
  345.  
  346.                       where BRDH = 1hex and BRDL = 80h (128 dec)
  347.  
  348.               FOR 1200 BAUD:
  349.  
  350.                       1,843,200
  351.               BRD =   ---------   =   96 or    1100000  or 60h
  352.                       16 x 1200
  353.                                                 B   B
  354.                                                 R   R
  355.                                                 D   D
  356.                       breaking the result into  H   L
  357.                       two bytes produces =      0 & 1100000
  358.  
  359.                       where BRDH = 0hex and BRDL = 60h (96 dec)
  360.  
  361.  
  362.        The THR (Transmit Holding Register) and RDR (Received Data Register)
  363.        are accessed via the same physical address as the port base address.
  364.        Since you cannot in theory send and receive at the same instant, this
  365.        little scheme seems ok.
  366.  
  367.  
  368.  
  369.        IIR  BIT MAPPING   (Interrupt Identification Register)
  370.        ---------------------------------------------
  371.        BIT
  372.        0    =  more than 1 intr has occurred
  373.  
  374.                12                       12
  375.        1-2  =  00  change in MSR        10    data received
  376.                01  THR empty            11    recv error/break
  377.  
  378.        3    =  zero
  379.        4    =  zero
  380.        5    =  zero
  381.        6    =  zero
  382.        7    =  zero
  383.  
  384.  
  385.        LCR  BIT MAPPING   (Line Control Register)
  386.        ---------------------------------------------
  387.        BIT                      01                 01
  388.        01   =  Data Length      00=5bits           10=7bits
  389.                                 01=6bits           11=8bits
  390.  
  391.        2    =  Stop Bits        0=1bit             1=2bits
  392.  
  393.                                 345                345
  394.        345  =  Parity           000=NONE           101=MARK
  395.                                 100=ODD            111=SPACE
  396.                                 110=EVEN
  397.  
  398.        6    =  Break Condition  0=disabled         1=enabled
  399.        7    =  Port Toggle      0=Use THR/RDR/IER  1=Use BRDL/BRDH
  400.  
  401.  
  402.        SAMPLE: Using N parity, 8 data bits and 1 stop bit requires
  403.        the LCR register of 00000000 to be then set as follows:
  404.                            76543210 = bit pattern
  405.                                  11 = 8 bits
  406.                                 0   = 1 stop bit
  407.                              000    = no parity
  408.                             0       = break disabled
  409.                            0        = toggle inactive
  410.                          ----------
  411.                            00000011 = 3h to send to LCR
  412.  
  413.  
  414.        Bit 7 of LCR controls the dual function of bits 0 and 1 in the
  415.        IER Register and should be set to zero in the above example.
  416.  
  417.  
  418.  
  419.        MCR  BIT MAPPING   (Modem Control Register)
  420.        ---------------------------------------------
  421.        BIT
  422.        0    =  Set DTR line active
  423.        1    =  Set RTS line active
  424.        2    =  USER BIT #1
  425.        3    =  USER BIT #2
  426.        4    =  UART loopback
  427.        5    =  zero
  428.        6    =  zero
  429.        7    =  zero
  430.  
  431.        Bit 3 is normally set to 1 for interrupt driven terminal
  432.        programs. Most programs force the modem to hang up by setting
  433.        bits 0 and 1 to 0. Modem software setup for these first two bits
  434.        therefore is usually 1 and 1.
  435.  
  436.  
  437.        LSR  BIT MAPPING   (Line Status Register)
  438.        ---------------------------------------------
  439.        BIT
  440.        0    =  byte in RDR (received)
  441.        1    =  overrun in RDR
  442.        2    =  Parity error detected
  443.        3    =  Framing error (out of sync, no stop bit received)
  444.        4    =  Break Detect
  445.        5    =  THR empty
  446.        6    =  TSR empty (removes char from THR)
  447.        7    =  Time Out
  448.  
  449.  
  450.        A communications program usually checks bit 5 here before sending
  451.        another character out the base port.
  452.  
  453.  
  454.        MSR  BIT MAPPING   (Modem Status Register)
  455.        ---------------------------------------------
  456.        BIT
  457.        0    =  change in [C]lear [T]o [S]end  CTS
  458.        1    =  change in [D]ata [S]et [R]eady DSR
  459.        2    =  change in ring indicator RI
  460.        3    =  change in [D]ata [C]arrier [D]etect  DCD
  461.        4    =  Clear to send ..... [CTS] set high
  462.        5    =  Data set ready .... [DSR] set high
  463.        6    =  Ring Indicator .... [RI]  set high
  464.        7    =  Data Carrier detect [DCD] set high
  465.  
  466.        Most BBS programs monitor bit 7 of the MSR to determine
  467.        if carrier is lost during a logon.
  468.  
  469.    ===================================================================
  470.        BAUD RATE DIVISOR (BRD Register) CHART
  471.  
  472.        Bit Rate            BRDH           BRDL
  473.        ---------------------------------------
  474.        50                   09h            00h
  475.        110                  04h            17h
  476.        300                  01h            80h
  477.        ---------------------------------------
  478.        1200                 00h            60h   From 1200 up, BRDH is
  479.        2400                 00h            30h   always set to zero!
  480.        4800                 00h            18h
  481.        9600                 00h            0Ch
  482.        19200                00h            06h
  483.  
  484.    ===================================================================
  485.  
  486.    Registering your copy will help continue the competitive advantages
  487.    of providing economical shareware. As an additional bonus, I will
  488.    ship you several other useful modem and dos utilities free!  If
  489.    you have any comments or suggestions about this utility, feel free
  490.    to write or call.
  491.  
  492.    Name_____________________________________________________________
  493.  
  494.    Mailing Address__________________________________________________
  495.  
  496.    City & State ___________________________________________________
  497.  
  498.    ZIP _____________________________ Phone _________________________
  499.  
  500.    Send $4 + $1 (ship & hand) check or money order to:
  501.  
  502.                               Gary M. Raymond
  503.                                 P.O.Box 8184
  504.                             New Orleans, La. 70182
  505.                                 504-288-6550
  506.                             Compuserve 70613,3165
  507.    ====================================================================
  508.                                      EOF
  509.  
  510.